<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        我是{{username}},今年{{userage}}
    </div>

</body>
<script>

    function Vue(option) {
        this.target = document.querySelector(option.el);
        // let str = this.target.innerHTML;
        // var str = this.target.innerHTML;
        // this.target.innerHTML = str.replace("{{username}}", option.data.username);
        // var str = this.target.innerHTML;
        // this.target.innerHTML = str.replace("{{userage}}", option.data.userage);

        for (var attr in option.data) {
            let str = this.target.innerHTML;
            this.target.innerHTML = str.replace(`{{${attr}}}`, option.data[attr]);

        }
    }

    var app = new Vue({
        el: "#app",
        data: {
            username: "tzj",
            userage: 18
        }

    })

</script>

</html>